*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      mec_labor_supply.do                             *;
*       Date:           12/28/2020                                      *;
*       Authora:        Baccini, Guidi, Poletti, and Yildirim           *;
*       Purpose:        Replication of "Trade Liberalization and Labor  *;
*						Market Institutions"                            *;                                                                      
*       Input Files:    mec_labor_supply.dta 					        *; 
*       Output Files:   mec_labor_supply_logfile.log                    *;
*       Machine:        Office                                          *;
*       Program: 		Stata 15                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

* Setting initial commands
clear
clear matrix
clear mata
set maxvar 50000
set matsize 11000
set more off 

* Loading the dataset
*cd "Replication File"
use mec_labor_supply, clear
log using mec_labor_supply_logfile.log

* Figure 5
fracreg logit labor_share c.tariff_cut_export##i.coord_dummy ln_kl c.ln_kl#i.coord_dummy MFN c.MFN#i.coord_du hhi c.hhi#i.coord_du i.id_country i.id_naics i.year [pweight=ln_labor], vce(cluster id_country_year)
outreg2 using tableD1.xls, bdec(3) tdec(2) addtext(Controls, Yes, Country-year fixed effects, No, Industry fixed effects, Yes, Country fixed efects, Yes, Year fixed effects, Yes) keep(c.tariff_cut_export##i.coord_dummy) label append
margins, at(tariff_cut_export=(0(5)30)) dydx(coord_dummy)
marginsplot, addplot((histogram tariff_cut_export if tariff_cut_export<=30, percent fcolor(none) lcolor(gs1) yaxis(2) yscale(alt  axis(2)))) level(90)
graph save Graph "C:\Users\lbacci\Dropbox\Projects\NNTT_VoC\Draft\LaTex\IO\Revisions\000 Check\Figure5.gph"
graph save Graph "C:\Users\lbacci\Dropbox\Projects\NNTT_VoC\Draft\LaTex\IO\Revisions\000 Check\Figure5.pdf"
